#!/usr/bin/env python

#import public lib
import sys
import getopt
import string

#import private lib 
import validator
import ActionController
from CommonLib import show_profile_list
from CommonLib import show_help_message


try:
    
    opts, args = getopt.getopt(sys.argv[1:], "p:s:lh", ["action="])
    
    profile_id = ''
    action = ''
    
    for o, a in opts:
        
        if o in ("-p"):
            
            profile_id = a
        
        if o in ("-s"):
            
            profile_id = a
        
        if o in ("-l"):
            
            show_profile_list()

        if o in ("-h"):
            
            show_help_message()
                   
        if o in ("--action"):

            action = string.upper(a)
            
    #check the profile is exist or not
    if profile_id != '':
        
        if validator.check_profile(profile_id):
        
            ActionController.action(profile_id, action)
           
        else:
            
            print 'the profile: ' + profile_id + ' is not exist. ' 

except getopt.GetoptError:
    
    #print error message and exit
    print 'the option is not valid.'
    sys.exit()



    
    
    